/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package logo;

import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import tortues.Tortue;
import tortues.TortueAmelioree;

/**
 *
 * @author Quentin
 */
/**
 *
 * @author p0907654
 */
public class GereTourThread extends Thread {

    private Boolean continuer = false;
    private FeuilleDessin mFeuille = null;
    private static final int INT_CSTE_JOIN = 100;

    public GereTourThread(FeuilleDessin mFeuilleIn) {
        continuer = true;
        mFeuille = mFeuilleIn;
    }

    public void setContinuer(Boolean continuer) {
        this.continuer = continuer;
    }

    public Boolean getContinuer() {
        return continuer;
    }
    
    
    @Override
    public void run() {
        try {
            Random mRandom = new Random();
            //for (int j = 0; j < 20; j++) {
            while (continuer) {
                for (Tortue t : mFeuille.getMesTortues()) {
                    if( t.getClass().toString().compareTo(TortueAmelioree.class.toString())==0)
                        ((TortueAmelioree)t).bouger(mRandom);
                }
                mFeuille.updateUI();
                GereTourThread.this.join(INT_CSTE_JOIN);
            }

        } catch (Exception ex) {
            Logger.getLogger(SimpleLogo.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
